var longestPalindrome = function (s) {
    if (s.length === 1) {
        return s
    }
    var maxStr = '', maxLength = 0
    for (let i = 0; i <= s.length - 1; i++) {
        for (let j = s.length - 1; j >= 0; j--) {
            var str = isHuiweng(s, i, j)
            /* console.log(str); */
            if (str !== false && str.length > maxLength) {
                maxLength = str.length
                maxStr = str
            }
        }
    }
    return maxStr

}
var isHuiweng = function (str, begin, end) {
    let l = begin, r = end;
    while (l < r) {
        if (str[l] != str[r]) {
            return false
        }
        l++
        r--
    }
    return str.slice(begin, end + 1)
}
var strTest = '2'
var test = longestPalindrome(strTest)
/* console.log(test); */